class CreateEquivalentTimeUnits < ActiveRecord::Migration
  def self.up
    create_table :equivalent_time_units do |t|
      t.references :time_unit
      t.integer :equivalent_to_id

      t.timestamps
    end

    add_index(:equivalent_time_units, [:time_unit_id, :equivalent_to_id],
      :unique => true, :name => "equivalent_time_units_tuid_eid")
    add_index(:equivalent_time_units, :time_unit_id, :unique => false)
  end

  def self.down
    remove_index(:equivalent_time_units, :name => "equivalent_time_units_tuid_eid")
    remove_index(:equivalent_time_units, :column => :time_unit_id)
    drop_table :equivalent_time_units
  end
end
